<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>SFML - Simple and Fast Multimedia Library</title>
        <meta http-equiv="Content-Type" content="text/html;"/>
        <meta charset="utf-8"/>
        <!--<link rel='stylesheet' type='text/css' href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>-->
        <link rel="stylesheet" type="text/css" href="doxygen.css" title="default" media="screen,print" />
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="dynsections.js"></script>
        <link rel="stylesheet" type="text/css" href="search/search.css" />
        <link rel="stylesheet" type="text/css" href="searchOverrides.css" />
        <script type="text/javascript" src="search/searchdata.js"></script>
        <script type="text/javascript" src="search/search.js"></script>
        <script type="text/javascript">
        /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
          $(document).ready(function() { init_search(); });
        /* @license-end */
        </script>
    </head>
    <body>
        <div id="banner-container">
            <div id="banner">
                <span id="sfml">SFML 2.6.1</span>
            </div>
        </div>
        <div id="content">
<!-- Generated by Doxygen 1.9.7 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <span id="MSearchSelect"                onmouseover="return searchBox.OnSearchSelectShow()"                onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
          <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>sf</b></li><li class="navelem"><a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#friends">Friends</a> &#124;
<a href="classsf_1_1SoundBuffer-members.html">List of all members</a>  </div>
  <div class="headertitle"><div class="title">sf::SoundBuffer Class Reference<div class="ingroups"><a class="el" href="group__audio.html">Audio module</a></div></div></div>
</div><!--header-->
<div class="contents">

<p>Storage for audio samples defining a sound.  
 <a href="classsf_1_1SoundBuffer.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="SoundBuffer_8hpp_source.html">SFML/Audio/SoundBuffer.hpp</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for sf::SoundBuffer:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classsf_1_1SoundBuffer.png" usemap="#sf::SoundBuffer_map" alt=""/>
  <map id="sf::SoundBuffer_map" name="sf::SoundBuffer_map">
<area href="classsf_1_1AlResource.html" title="Base class for classes that require an OpenAL context." alt="sf::AlResource" shape="rect" coords="0,0,99,24"/>
  </map>
</div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a0cabfbfe19b831bf7d5c9592d92ef233"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#a0cabfbfe19b831bf7d5c9592d92ef233">SoundBuffer</a> ()</td></tr>
<tr class="memdesc:a0cabfbfe19b831bf7d5c9592d92ef233"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default constructor.  <br /></td></tr>
<tr class="separator:a0cabfbfe19b831bf7d5c9592d92ef233"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaf000fc741ff27015907e8588263f4a6"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#aaf000fc741ff27015907e8588263f4a6">SoundBuffer</a> (const <a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp;copy)</td></tr>
<tr class="memdesc:aaf000fc741ff27015907e8588263f4a6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy constructor.  <br /></td></tr>
<tr class="separator:aaf000fc741ff27015907e8588263f4a6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aea240161724ffba74a0d6a9e277d3cd5"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#aea240161724ffba74a0d6a9e277d3cd5">~SoundBuffer</a> ()</td></tr>
<tr class="memdesc:aea240161724ffba74a0d6a9e277d3cd5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destructor.  <br /></td></tr>
<tr class="separator:aea240161724ffba74a0d6a9e277d3cd5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2be6a8025c97eb622a7dff6cf2594394"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#a2be6a8025c97eb622a7dff6cf2594394">loadFromFile</a> (const std::string &amp;filename)</td></tr>
<tr class="memdesc:a2be6a8025c97eb622a7dff6cf2594394"><td class="mdescLeft">&#160;</td><td class="mdescRight">Load the sound buffer from a file.  <br /></td></tr>
<tr class="separator:a2be6a8025c97eb622a7dff6cf2594394"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af8cfa5599739a7edae69c5cba273d33f"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#af8cfa5599739a7edae69c5cba273d33f">loadFromMemory</a> (const void *data, std::size_t sizeInBytes)</td></tr>
<tr class="memdesc:af8cfa5599739a7edae69c5cba273d33f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Load the sound buffer from a file in memory.  <br /></td></tr>
<tr class="separator:af8cfa5599739a7edae69c5cba273d33f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad292156b1e01f6dabd4c0c277d5e079e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#ad292156b1e01f6dabd4c0c277d5e079e">loadFromStream</a> (<a class="el" href="classsf_1_1InputStream.html">InputStream</a> &amp;stream)</td></tr>
<tr class="memdesc:ad292156b1e01f6dabd4c0c277d5e079e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Load the sound buffer from a custom stream.  <br /></td></tr>
<tr class="separator:ad292156b1e01f6dabd4c0c277d5e079e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a42d51ce4bb3b60c7ea06f63c273fd063"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#a42d51ce4bb3b60c7ea06f63c273fd063">loadFromSamples</a> (const Int16 *samples, Uint64 sampleCount, unsigned int channelCount, unsigned int sampleRate)</td></tr>
<tr class="memdesc:a42d51ce4bb3b60c7ea06f63c273fd063"><td class="mdescLeft">&#160;</td><td class="mdescRight">Load the sound buffer from an array of audio samples.  <br /></td></tr>
<tr class="separator:a42d51ce4bb3b60c7ea06f63c273fd063"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aade64260c6375580a085314a30be007e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#aade64260c6375580a085314a30be007e">saveToFile</a> (const std::string &amp;filename) const</td></tr>
<tr class="memdesc:aade64260c6375580a085314a30be007e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Save the sound buffer to an audio file.  <br /></td></tr>
<tr class="separator:aade64260c6375580a085314a30be007e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3d5571a5231d3aea0d2cea933c38cc9e"><td class="memItemLeft" align="right" valign="top">const Int16 *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#a3d5571a5231d3aea0d2cea933c38cc9e">getSamples</a> () const</td></tr>
<tr class="memdesc:a3d5571a5231d3aea0d2cea933c38cc9e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the array of audio samples stored in the buffer.  <br /></td></tr>
<tr class="separator:a3d5571a5231d3aea0d2cea933c38cc9e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aebe2a4bdbfbd9249353748da3f6a4fa1"><td class="memItemLeft" align="right" valign="top">Uint64&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#aebe2a4bdbfbd9249353748da3f6a4fa1">getSampleCount</a> () const</td></tr>
<tr class="memdesc:aebe2a4bdbfbd9249353748da3f6a4fa1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the number of samples stored in the buffer.  <br /></td></tr>
<tr class="separator:aebe2a4bdbfbd9249353748da3f6a4fa1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2c2cf0078ce0549246ecc4a1646212b4"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#a2c2cf0078ce0549246ecc4a1646212b4">getSampleRate</a> () const</td></tr>
<tr class="memdesc:a2c2cf0078ce0549246ecc4a1646212b4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the sample rate of the sound.  <br /></td></tr>
<tr class="separator:a2c2cf0078ce0549246ecc4a1646212b4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a127707b831d875ed790eef1aa2b9fcc3"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#a127707b831d875ed790eef1aa2b9fcc3">getChannelCount</a> () const</td></tr>
<tr class="memdesc:a127707b831d875ed790eef1aa2b9fcc3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the number of channels used by the sound.  <br /></td></tr>
<tr class="separator:a127707b831d875ed790eef1aa2b9fcc3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a280a581d9b360fd16121714c51fc8261"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classsf_1_1Time.html">Time</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#a280a581d9b360fd16121714c51fc8261">getDuration</a> () const</td></tr>
<tr class="memdesc:a280a581d9b360fd16121714c51fc8261"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the total duration of the sound.  <br /></td></tr>
<tr class="separator:a280a581d9b360fd16121714c51fc8261"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad0b6f45d3008cd7d29d340195e68459a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#ad0b6f45d3008cd7d29d340195e68459a">operator=</a> (const <a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp;right)</td></tr>
<tr class="memdesc:ad0b6f45d3008cd7d29d340195e68459a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Overload of assignment operator.  <br /></td></tr>
<tr class="separator:ad0b6f45d3008cd7d29d340195e68459a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="friends" name="friends"></a>
Friends</h2></td></tr>
<tr class="memitem:a50914f77c7cf4fb97616c898c5291f4b"><td class="memItemLeft" align="right" valign="top">class&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.html#a50914f77c7cf4fb97616c898c5291f4b">Sound</a></td></tr>
<tr class="separator:a50914f77c7cf4fb97616c898c5291f4b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Storage for audio samples defining a sound. </p>
<p>A sound buffer holds the data of a sound, which is an array of audio samples.</p>
<p>A sample is a 16 bits signed integer that defines the amplitude of the sound at a given time. The sound is then reconstituted by playing these samples at a high rate (for example, 44100 samples per second is the standard rate used for playing CDs). In short, audio samples are like texture pixels, and a <a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a> is similar to a <a class="el" href="classsf_1_1Texture.html" title="Image living on the graphics card that can be used for drawing.">sf::Texture</a>.</p>
<p>A sound buffer can be loaded from a file (see <a class="el" href="classsf_1_1SoundBuffer.html#a2be6a8025c97eb622a7dff6cf2594394" title="Load the sound buffer from a file.">loadFromFile()</a> for the complete list of supported formats), from memory, from a custom stream (see <a class="el" href="classsf_1_1InputStream.html" title="Abstract class for custom file input streams.">sf::InputStream</a>) or directly from an array of samples. It can also be saved back to a file.</p>
<p><a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">Sound</a> buffers alone are not very useful: they hold the audio data but cannot be played. To do so, you need to use the <a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a> class, which provides functions to play/pause/stop the sound as well as changing the way it is outputted (volume, pitch, 3D position, ...). This separation allows more flexibility and better performances: indeed a <a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a> is a heavy resource, and any operation on it is slow (often too slow for real-time applications). On the other side, a <a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a> is a lightweight object, which can use the audio data of a sound buffer and change the way it is played without actually modifying that data. Note that it is also possible to bind several <a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a> instances to the same <a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a>.</p>
<p>It is important to note that the <a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a> instance doesn't copy the buffer that it uses, it only keeps a reference to it. Thus, a <a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a> must not be destructed while it is used by a <a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a> (i.e. never write a function that uses a local <a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a> instance for loading a sound).</p>
<p>Usage example: </p><div class="fragment"><div class="line"><span class="comment">// Declare a new sound buffer</span></div>
<div class="line"><a class="code hl_class" href="classsf_1_1SoundBuffer.html">sf::SoundBuffer</a> buffer;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Load it from a file</span></div>
<div class="line"><span class="keywordflow">if</span> (!buffer.<a class="code hl_function" href="classsf_1_1SoundBuffer.html#a2be6a8025c97eb622a7dff6cf2594394">loadFromFile</a>(<span class="stringliteral">&quot;sound.wav&quot;</span>))</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// error...</span></div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create a sound source and bind it to the buffer</span></div>
<div class="line"><a class="code hl_class" href="classsf_1_1Sound.html">sf::Sound</a> sound1;</div>
<div class="line">sound1.<a class="code hl_function" href="classsf_1_1Sound.html#a8b395e9713d0efa48a18628c8ec1972e">setBuffer</a>(buffer);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Play the sound</span></div>
<div class="line">sound1.<a class="code hl_function" href="classsf_1_1Sound.html#a2953ffe632536e72e696fd880ced2532">play</a>();</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create another sound source bound to the same buffer</span></div>
<div class="line"><a class="code hl_class" href="classsf_1_1Sound.html">sf::Sound</a> sound2;</div>
<div class="line">sound2.<a class="code hl_function" href="classsf_1_1Sound.html#a8b395e9713d0efa48a18628c8ec1972e">setBuffer</a>(buffer);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Play it with a higher pitch -- the first sound remains unchanged</span></div>
<div class="line">sound2.<a class="code hl_function" href="classsf_1_1SoundSource.html#a72a13695ed48b7f7b55e7cd4431f4bb6">setPitch</a>(2);</div>
<div class="line">sound2.<a class="code hl_function" href="classsf_1_1Sound.html#a2953ffe632536e72e696fd880ced2532">play</a>();</div>
<div class="ttc" id="aclasssf_1_1SoundBuffer_html"><div class="ttname"><a href="classsf_1_1SoundBuffer.html">sf::SoundBuffer</a></div><div class="ttdoc">Storage for audio samples defining a sound.</div><div class="ttdef"><b>Definition</b> <a href="SoundBuffer_8hpp_source.html#l00049">SoundBuffer.hpp:50</a></div></div>
<div class="ttc" id="aclasssf_1_1SoundBuffer_html_a2be6a8025c97eb622a7dff6cf2594394"><div class="ttname"><a href="classsf_1_1SoundBuffer.html#a2be6a8025c97eb622a7dff6cf2594394">sf::SoundBuffer::loadFromFile</a></div><div class="ttdeci">bool loadFromFile(const std::string &amp;filename)</div><div class="ttdoc">Load the sound buffer from a file.</div></div>
<div class="ttc" id="aclasssf_1_1SoundSource_html_a72a13695ed48b7f7b55e7cd4431f4bb6"><div class="ttname"><a href="classsf_1_1SoundSource.html#a72a13695ed48b7f7b55e7cd4431f4bb6">sf::SoundSource::setPitch</a></div><div class="ttdeci">void setPitch(float pitch)</div><div class="ttdoc">Set the pitch of the sound.</div></div>
<div class="ttc" id="aclasssf_1_1Sound_html"><div class="ttname"><a href="classsf_1_1Sound.html">sf::Sound</a></div><div class="ttdoc">Regular sound that can be played in the audio environment.</div><div class="ttdef"><b>Definition</b> <a href="Sound_8hpp_source.html#l00045">Sound.hpp:46</a></div></div>
<div class="ttc" id="aclasssf_1_1Sound_html_a2953ffe632536e72e696fd880ced2532"><div class="ttname"><a href="classsf_1_1Sound.html#a2953ffe632536e72e696fd880ced2532">sf::Sound::play</a></div><div class="ttdeci">void play()</div><div class="ttdoc">Start or resume playing the sound.</div></div>
<div class="ttc" id="aclasssf_1_1Sound_html_a8b395e9713d0efa48a18628c8ec1972e"><div class="ttname"><a href="classsf_1_1Sound.html#a8b395e9713d0efa48a18628c8ec1972e">sf::Sound::setBuffer</a></div><div class="ttdeci">void setBuffer(const SoundBuffer &amp;buffer)</div><div class="ttdoc">Set the source buffer containing the audio data to play.</div></div>
</div><!-- fragment --><dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a>, <a class="el" href="classsf_1_1SoundBufferRecorder.html" title="Specialized SoundRecorder which stores the captured audio data into a sound buffer.">sf::SoundBufferRecorder</a> </dd></dl>

<p class="definition">Definition at line <a class="el" href="SoundBuffer_8hpp_source.html#l00049">49</a> of file <a class="el" href="SoundBuffer_8hpp_source.html">SoundBuffer.hpp</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a0cabfbfe19b831bf7d5c9592d92ef233" name="a0cabfbfe19b831bf7d5c9592d92ef233"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0cabfbfe19b831bf7d5c9592d92ef233">&#9670;&#160;</a></span>SoundBuffer() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">sf::SoundBuffer::SoundBuffer </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Default constructor. </p>

</div>
</div>
<a id="aaf000fc741ff27015907e8588263f4a6" name="aaf000fc741ff27015907e8588263f4a6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aaf000fc741ff27015907e8588263f4a6">&#9670;&#160;</a></span>SoundBuffer() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">sf::SoundBuffer::SoundBuffer </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp;&#160;</td>
          <td class="paramname"><em>copy</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Copy constructor. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">copy</td><td>Instance to copy </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="aea240161724ffba74a0d6a9e277d3cd5" name="aea240161724ffba74a0d6a9e277d3cd5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aea240161724ffba74a0d6a9e277d3cd5">&#9670;&#160;</a></span>~SoundBuffer()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">sf::SoundBuffer::~SoundBuffer </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Destructor. </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a127707b831d875ed790eef1aa2b9fcc3" name="a127707b831d875ed790eef1aa2b9fcc3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a127707b831d875ed790eef1aa2b9fcc3">&#9670;&#160;</a></span>getChannelCount()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int sf::SoundBuffer::getChannelCount </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the number of channels used by the sound. </p>
<p>If the sound is mono then the number of channels will be 1, 2 for stereo, etc.</p>
<dl class="section return"><dt>Returns</dt><dd>Number of channels</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.html#a2c2cf0078ce0549246ecc4a1646212b4" title="Get the sample rate of the sound.">getSampleRate</a>, <a class="el" href="classsf_1_1SoundBuffer.html#a280a581d9b360fd16121714c51fc8261" title="Get the total duration of the sound.">getDuration</a> </dd></dl>

</div>
</div>
<a id="a280a581d9b360fd16121714c51fc8261" name="a280a581d9b360fd16121714c51fc8261"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a280a581d9b360fd16121714c51fc8261">&#9670;&#160;</a></span>getDuration()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classsf_1_1Time.html">Time</a> sf::SoundBuffer::getDuration </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the total duration of the sound. </p>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">Sound</a> duration</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.html#a2c2cf0078ce0549246ecc4a1646212b4" title="Get the sample rate of the sound.">getSampleRate</a>, <a class="el" href="classsf_1_1SoundBuffer.html#a127707b831d875ed790eef1aa2b9fcc3" title="Get the number of channels used by the sound.">getChannelCount</a> </dd></dl>

</div>
</div>
<a id="aebe2a4bdbfbd9249353748da3f6a4fa1" name="aebe2a4bdbfbd9249353748da3f6a4fa1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aebe2a4bdbfbd9249353748da3f6a4fa1">&#9670;&#160;</a></span>getSampleCount()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Uint64 sf::SoundBuffer::getSampleCount </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the number of samples stored in the buffer. </p>
<p>The array of samples can be accessed with the <a class="el" href="classsf_1_1SoundBuffer.html#a3d5571a5231d3aea0d2cea933c38cc9e" title="Get the array of audio samples stored in the buffer.">getSamples()</a> function.</p>
<dl class="section return"><dt>Returns</dt><dd>Number of samples</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.html#a3d5571a5231d3aea0d2cea933c38cc9e" title="Get the array of audio samples stored in the buffer.">getSamples</a> </dd></dl>

</div>
</div>
<a id="a2c2cf0078ce0549246ecc4a1646212b4" name="a2c2cf0078ce0549246ecc4a1646212b4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2c2cf0078ce0549246ecc4a1646212b4">&#9670;&#160;</a></span>getSampleRate()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int sf::SoundBuffer::getSampleRate </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the sample rate of the sound. </p>
<p>The sample rate is the number of samples played per second. The higher, the better the quality (for example, 44100 samples/s is CD quality).</p>
<dl class="section return"><dt>Returns</dt><dd>Sample rate (number of samples per second)</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.html#a127707b831d875ed790eef1aa2b9fcc3" title="Get the number of channels used by the sound.">getChannelCount</a>, <a class="el" href="classsf_1_1SoundBuffer.html#a280a581d9b360fd16121714c51fc8261" title="Get the total duration of the sound.">getDuration</a> </dd></dl>

</div>
</div>
<a id="a3d5571a5231d3aea0d2cea933c38cc9e" name="a3d5571a5231d3aea0d2cea933c38cc9e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3d5571a5231d3aea0d2cea933c38cc9e">&#9670;&#160;</a></span>getSamples()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const Int16 * sf::SoundBuffer::getSamples </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the array of audio samples stored in the buffer. </p>
<p>The format of the returned samples is 16 bits signed integer (sf::Int16). The total number of samples in this array is given by the <a class="el" href="classsf_1_1SoundBuffer.html#aebe2a4bdbfbd9249353748da3f6a4fa1" title="Get the number of samples stored in the buffer.">getSampleCount()</a> function.</p>
<dl class="section return"><dt>Returns</dt><dd>Read-only pointer to the array of sound samples</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.html#aebe2a4bdbfbd9249353748da3f6a4fa1" title="Get the number of samples stored in the buffer.">getSampleCount</a> </dd></dl>

</div>
</div>
<a id="a2be6a8025c97eb622a7dff6cf2594394" name="a2be6a8025c97eb622a7dff6cf2594394"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2be6a8025c97eb622a7dff6cf2594394">&#9670;&#160;</a></span>loadFromFile()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool sf::SoundBuffer::loadFromFile </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>filename</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Load the sound buffer from a file. </p>
<p>See the documentation of <a class="el" href="classsf_1_1InputSoundFile.html" title="Provide read access to sound files.">sf::InputSoundFile</a> for the list of supported formats.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">filename</td><td>Path of the sound file to load</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>True if loading succeeded, false if it failed</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.html#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a>, <a class="el" href="classsf_1_1SoundBuffer.html#ad292156b1e01f6dabd4c0c277d5e079e" title="Load the sound buffer from a custom stream.">loadFromStream</a>, <a class="el" href="classsf_1_1SoundBuffer.html#a42d51ce4bb3b60c7ea06f63c273fd063" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a>, <a class="el" href="classsf_1_1SoundBuffer.html#aade64260c6375580a085314a30be007e" title="Save the sound buffer to an audio file.">saveToFile</a> </dd></dl>

</div>
</div>
<a id="af8cfa5599739a7edae69c5cba273d33f" name="af8cfa5599739a7edae69c5cba273d33f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af8cfa5599739a7edae69c5cba273d33f">&#9670;&#160;</a></span>loadFromMemory()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool sf::SoundBuffer::loadFromMemory </td>
          <td>(</td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::size_t&#160;</td>
          <td class="paramname"><em>sizeInBytes</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Load the sound buffer from a file in memory. </p>
<p>See the documentation of <a class="el" href="classsf_1_1InputSoundFile.html" title="Provide read access to sound files.">sf::InputSoundFile</a> for the list of supported formats.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">data</td><td>Pointer to the file data in memory </td></tr>
    <tr><td class="paramname">sizeInBytes</td><td>Size of the data to load, in bytes</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>True if loading succeeded, false if it failed</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.html#a2be6a8025c97eb622a7dff6cf2594394" title="Load the sound buffer from a file.">loadFromFile</a>, <a class="el" href="classsf_1_1SoundBuffer.html#ad292156b1e01f6dabd4c0c277d5e079e" title="Load the sound buffer from a custom stream.">loadFromStream</a>, <a class="el" href="classsf_1_1SoundBuffer.html#a42d51ce4bb3b60c7ea06f63c273fd063" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a> </dd></dl>

</div>
</div>
<a id="a42d51ce4bb3b60c7ea06f63c273fd063" name="a42d51ce4bb3b60c7ea06f63c273fd063"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a42d51ce4bb3b60c7ea06f63c273fd063">&#9670;&#160;</a></span>loadFromSamples()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool sf::SoundBuffer::loadFromSamples </td>
          <td>(</td>
          <td class="paramtype">const Int16 *&#160;</td>
          <td class="paramname"><em>samples</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Uint64&#160;</td>
          <td class="paramname"><em>sampleCount</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>channelCount</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>sampleRate</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Load the sound buffer from an array of audio samples. </p>
<p>The assumed format of the audio samples is 16 bits signed integer (sf::Int16).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">samples</td><td>Pointer to the array of samples in memory </td></tr>
    <tr><td class="paramname">sampleCount</td><td>Number of samples in the array </td></tr>
    <tr><td class="paramname">channelCount</td><td>Number of channels (1 = mono, 2 = stereo, ...) </td></tr>
    <tr><td class="paramname">sampleRate</td><td>Sample rate (number of samples to play per second)</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>True if loading succeeded, false if it failed</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.html#a2be6a8025c97eb622a7dff6cf2594394" title="Load the sound buffer from a file.">loadFromFile</a>, <a class="el" href="classsf_1_1SoundBuffer.html#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a>, <a class="el" href="classsf_1_1SoundBuffer.html#aade64260c6375580a085314a30be007e" title="Save the sound buffer to an audio file.">saveToFile</a> </dd></dl>

</div>
</div>
<a id="ad292156b1e01f6dabd4c0c277d5e079e" name="ad292156b1e01f6dabd4c0c277d5e079e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad292156b1e01f6dabd4c0c277d5e079e">&#9670;&#160;</a></span>loadFromStream()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool sf::SoundBuffer::loadFromStream </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classsf_1_1InputStream.html">InputStream</a> &amp;&#160;</td>
          <td class="paramname"><em>stream</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Load the sound buffer from a custom stream. </p>
<p>See the documentation of <a class="el" href="classsf_1_1InputSoundFile.html" title="Provide read access to sound files.">sf::InputSoundFile</a> for the list of supported formats.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">stream</td><td>Source stream to read from</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>True if loading succeeded, false if it failed</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.html#a2be6a8025c97eb622a7dff6cf2594394" title="Load the sound buffer from a file.">loadFromFile</a>, <a class="el" href="classsf_1_1SoundBuffer.html#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a>, <a class="el" href="classsf_1_1SoundBuffer.html#a42d51ce4bb3b60c7ea06f63c273fd063" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a> </dd></dl>

</div>
</div>
<a id="ad0b6f45d3008cd7d29d340195e68459a" name="ad0b6f45d3008cd7d29d340195e68459a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad0b6f45d3008cd7d29d340195e68459a">&#9670;&#160;</a></span>operator=()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp; sf::SoundBuffer::operator= </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp;&#160;</td>
          <td class="paramname"><em>right</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Overload of assignment operator. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">right</td><td>Instance to assign</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Reference to self </dd></dl>

</div>
</div>
<a id="aade64260c6375580a085314a30be007e" name="aade64260c6375580a085314a30be007e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aade64260c6375580a085314a30be007e">&#9670;&#160;</a></span>saveToFile()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool sf::SoundBuffer::saveToFile </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>filename</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Save the sound buffer to an audio file. </p>
<p>See the documentation of <a class="el" href="classsf_1_1OutputSoundFile.html" title="Provide write access to sound files.">sf::OutputSoundFile</a> for the list of supported formats.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">filename</td><td>Path of the sound file to write</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>True if saving succeeded, false if it failed</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.html#a2be6a8025c97eb622a7dff6cf2594394" title="Load the sound buffer from a file.">loadFromFile</a>, <a class="el" href="classsf_1_1SoundBuffer.html#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a>, <a class="el" href="classsf_1_1SoundBuffer.html#a42d51ce4bb3b60c7ea06f63c273fd063" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a> </dd></dl>

</div>
</div>
<h2 class="groupheader">Friends And Related Symbol Documentation</h2>
<a id="a50914f77c7cf4fb97616c898c5291f4b" name="a50914f77c7cf4fb97616c898c5291f4b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a50914f77c7cf4fb97616c898c5291f4b">&#9670;&#160;</a></span>Sound</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">friend class <a class="el" href="classsf_1_1Sound.html">Sound</a></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">friend</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="SoundBuffer_8hpp_source.html#l00228">228</a> of file <a class="el" href="SoundBuffer_8hpp_source.html">SoundBuffer.hpp</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="SoundBuffer_8hpp_source.html">SoundBuffer.hpp</a></li>
</ul>
</div><!-- contents -->
        </div>
        <div id="footer-container">
            <div id="footer">
                SFML is licensed under the terms and conditions of the <a href="https://www.sfml-dev.org/license.php">zlib/png license</a>.<br>
                Copyright &copy; Laurent Gomila &nbsp;::&nbsp;
                Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen</a> &nbsp;::&nbsp;
            </div>
        </div>
    </body>
</html>
